package so.sao.shop.supplier.pojo.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import so.sao.shop.supplier.config.Constant;
import so.sao.shop.supplier.util.StringAndDateUtil;

import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 订单表对应的vo类
 * </p>
 *
 * @author 透云-中软-西安项目组-zhenhai.zheng
 * @since 2017年7月20日
 **/
@Getter
@Setter
public class AccountPurchaseVo {
    /**
     * 订单编号
     */
    private String orderId;

    /**
     * 订单状态:1.待付款2.待发货3.已发货4.已完成5.已拒收退款审核6.已退款7.已支付退款审核8.待付款已取消9.退款中10.审核通过11.拒绝退款12.已收货19.确认送达
     */
    private Integer orderStatus;

    /**
     * 商品金额小计
     */
    private BigDecimal orderPrice;

    /**
     * 运费金额
     */
    private BigDecimal orderPostage;

    /**
     * 折扣优惠
     */
    private BigDecimal discount;

    /**
     * 总计金额
     */
    private BigDecimal orderTotalPrice;

    /**
     * 实付金额
     */
    private BigDecimal payAmount;

    /**
     * 透云进货价小计
     */
    private BigDecimal orderSettlemePrice;

    /**
     * 结算金额
     */
    private BigDecimal tempSettlemePrice;

    /**
     * 付款时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date orderPaymentTime;

    /**
     * 支付类型 1.支付宝 2.微信
     */
    private Integer orderPaymentMethod;

    /**
     * 付款流水号
     */
    private String orderPaymentNum;

    /**
     * 透云进货价小计
     */
    private BigDecimal orderDealerPrice;

    /**
     * 核账时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date checkAccountsTime;

    public static Object[] converData(AccountPurchaseVo accountPurchaseVo) {
        Object[] data = new Object[13];

        if (null != accountPurchaseVo) {
            //订单编号
            data[0] = accountPurchaseVo.getOrderId();
            //订单状态:1.待付款2.待发货3.已发货4.已完成5.已拒收退款审核6.已退款7.已支付退款审核8.待付款已取消9.退款中10.审核通过11.拒绝退款12.已收货19.确认送达
            switch (accountPurchaseVo.getOrderStatus()) {
                case 1:
                    data[1] = "待付款";
                    break;
                case 2:
                    data[1] = "待发货";
                    break;
                case 3:
                    data[1] = "已发货";
                    break;
                case 4:
                    data[1] = "已完成";
                    break;
                case 5:
                    data[1] = "已拒收退款审核";
                    break;
                case 6:
                    data[1] = "已退款";
                    break;
                case 7:
                    data[1] = "已支付退款审核";
                    break;
                case 8:
                    data[1] = "待付款已取消";
                    break;
                case 9:
                    data[1] = "退款中";
                    break;
                case 10:
                    data[1] = "审核通过";
                    break;
                case 11:
                    data[1] = "拒绝退款";
                    break;
                case 12:
                    data[1] = "已收货";
                    break;
                case 19:
                    data[1] = "确认送达";
                    break;
                default:
                    data[1] = "";
                    break;
            }

            //商品金额小计
            data[2] = accountPurchaseVo.getOrderPrice();
            //运费金额
            data[3] = accountPurchaseVo.getOrderPostage();
            //折扣优惠
            data[4] = accountPurchaseVo.getDiscount();
            //总计金额
            data[5] = accountPurchaseVo.getOrderTotalPrice();
            //实付金额
            data[6] = accountPurchaseVo.getPayAmount();
            //透云进货价小计
            data[7] = accountPurchaseVo.getOrderDealerPrice();
            //结算金额
            data[8] = accountPurchaseVo.getTempSettlemePrice();
            //付款时间
            data[9] = accountPurchaseVo.getOrderPaymentTime() == null ? "" : StringAndDateUtil.fomateData(accountPurchaseVo.getOrderPaymentTime(), "yyyy-MM-dd HH:mm:ss");
            //支付类型 1.支付宝 2.微信
            Integer orderPaymentMethod = accountPurchaseVo.getOrderPaymentMethod();
            if (orderPaymentMethod != null && orderPaymentMethod.equals(Constant.PaymentStatusConfig.ALIPAY)) {
                data[10] = "支付宝";
            } else if (orderPaymentMethod != null && orderPaymentMethod.equals(Constant.PaymentStatusConfig.WECHAT)) {
                data[10] = "微信";
            } else {
                data[10] = "";
            }
            //付款流水号
            data[11] = accountPurchaseVo.getOrderPaymentNum();
            //核账时间
            data[12] = accountPurchaseVo.getCheckAccountsTime() == null ? "" : StringAndDateUtil.fomateData(accountPurchaseVo.getCheckAccountsTime(), "yyyy-MM-dd HH:mm:ss");
        }
        return data;
    }

}
